Snippets Collections
// Add this code in your theme's functions.php file or in a custom plugin
2
​
3
function update_all_ai_tools_posts_highlight_product_meta() {
4
    // Get all posts of the "ai-tools" post type
5
    $args = array(
6
        'post_type' => 'ai-tools',
7
        'posts_per_page' => -1, // Retrieve all posts
8
    );
9
​
10
    $ai_tools_posts = new WP_Query($args);
11
​
12
    if ($ai_tools_posts->have_posts()) {
13
        while ($ai_tools_posts->have_posts()) {
14
            $ai_tools_posts->the_post();
15
​
16
            // Update the "highlight-product" meta field to "none"
17
            update_post_meta(get_the_ID(), 'highlight-product', 'none');
18
        }
19
​
20
        // Reset post data
21
        wp_reset_postdata();

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension